Namespace: Wintellect.PowerCollections
Assembly:
PowerCollections (in PowerCollections.dll)
Syntax
C# |
---|
[SerializableAttribute] public class BigList<T> : ListBase<T>, ICloneable |
Visual Basic (Declaration) |
---|
<SerializableAttribute> _ Public Class BigList(Of T) _ Inherits ListBase(Of T) _ Implements ICloneable |
Visual C++ |
---|
[SerializableAttribute] generic<typename T> public ref class BigList : public ListBase<T>, ICloneable |
Type Parameters
- T
- The type of items to store in the BigList.
Remarks
BigList<T> class is similar in functionality to the standard List<T> class. Both classes provide a collection that stores an set of items in order, with indices of the items ranging from 0 to one less than the count of items in the collection. Both classes provide the ability to add and remove items from any index, and the get or set the item at any index.
BigList<T> differs significantly from List<T> in the performance of various operations, especially when the lists become large (several hundred items or more). With List<T>, inserting or removing elements from anywhere in a large list except the end is very inefficient -- every item after the point of inserting or deletion has to be moved in the list. The BigList<T> class, however, allows for fast insertions and deletions anywhere in the list. Furthermore, BigList<T> allows copies of a list, sub-parts of a list, and concatinations of two lists to be very fast. When a copy is made of part or all of a BigList, two lists shared storage for the parts of the lists that are the same. Only when one of the lists is changed is additional memory allocated to store the distinct parts of the lists.
Of course, there is a small price to pay for this extra flexibility. Although still quite efficient, using an index to get or change one element of a BigList, while still reasonably efficient, is significantly slower than using a plain List. Because of this, if you want to process every element of a BigList, using a foreach loop is a lot more efficient than using a for loop and indexing the list.
In general, use a List when the only operations you are using are Add (to the end), foreach, or indexing, or you are very sure the list will always remain small (less than 100 items). For large (>100 items) lists that do insertions, removals, copies, concatinations, or sub-ranges, BigList will be more efficient than List. In almost all cases, BigList is more efficient and easier to use than LinkedList.
Inheritance Hierarchy
Wintellect.PowerCollections..::CollectionBase<(Of <T>)>
Wintellect.PowerCollections..::ListBase<(Of <T>)>
Wintellect.PowerCollections..::BigList<(Of <T>)>